package com.cndym.adapterForMobile.mobile.function;

import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.cndym.adapterForMobile.BaseFunction;
import com.cndym.exception.ErrCode;
import com.cndym.utils.Utils;
import com.zch.matches.producer.ISportMatchesProducer;

/**
 * 查询比分直播的比赛
 * @author 朱林虎
 *
 */
@Component
public class SportMatchesFunc extends BaseFunction {
	private Logger logger = Logger.getLogger(getClass());
 
	@Autowired
	private ISportMatchesProducer sportMatchesProducer;
	
	@Override
	public Map<String, String> function(Map<String, String> map) {
		Map<String, String> paramMap = paraMap(map);
		
		if (Utils.isEmpty(paramMap.get("lotteryCode"))) {
			logger.error("彩种不存在，该请求无效！");
			return noBodyReMap(ErrCode.E3300);
		}
		if (Utils.isEmpty(paramMap.get("matchStatus"))) {
			logger.error("比赛状态不存在，该请求无效！");
			return noBodyReMap(ErrCode.E4502);
		}
		String matchStatus = paramMap.get("matchStatus");
		if ("3".equals(matchStatus)) {
			if (Utils.isEmpty(paramMap.get("userCode"))) {
				logger.error("查询关注的比赛,userCode不存在！");
				return noBodyReMap(ErrCode.E3004);
			}
		}
		Map<String, Object> resMap = null;
		resMap=sportMatchesProducer.sportMatches(paramMap);
		if (null == resMap) {
			return failure();
		}
		return successObj(resMap);
	}
	
	
}
